package threadDemo;

import org.apache.log4j.Logger;

import java.awt.*;
import java.util.Map;
import java.util.Set;

/**
 * Created by ${张英杰} on 2019/1/18.
 *
 */
public class WatchDogCommonMain{
    private static final Logger logger = Logger.getLogger(WatchDogCommonMain.class);

    public static void main(String[] args) {

        long startTime = System.currentTimeMillis();

        new Thread(new Runnable() {
            @Override
            public void run() {
                while(true&&(System.currentTimeMillis() - startTime < 8000)){
                    System.out.println("WatchDogCommonMain:run:---watch_1");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        },"watch_1").start();

        WatchDogMutilThread watchDogMutilThread = new WatchDogMutilThread(5 * 1000, new WatchDogMutilThread.WatchDogInterface() {
            @Override
            public void callThreadDead(String str) {
                System.err.println("watchDogMutilThread:callNoThread:"+str);
            }
        });
        watchDogMutilThread.addWatchThreadName("watch_1");
        watchDogMutilThread.addWatchThreadName("watch_2");
        watchDogMutilThread.start();
    }
}
